<?php
namespace app\admin\logic;
//订单页
use think\facade\Request;

class OrderLogic{
    //订单留值
    public static function  orderData(){
        $param=Request::param();
        $data=[
            'keywords'=>isset($param['keywords'])?$param['keywords']:'',
            'mintime'=>isset($param['mintime'])?$param['mintime']:'',
            'maxtime'=>isset($param['maxtime'])?$param['maxtime']:'',
            'order_status'=>isset($param['order_status'])?$param['order_status']:[],
            'minmoney'=>isset($param['minmoney'])?$param['minmoney']:'',
            'maxmoney'=>isset($param['maxmoney'])?$param['maxmoney']:'',
        ];

        return $data;
    }
    //order where语句
    public static function orderWhere(){
        $param=Request::param();
        $where=[];
        if (isset($param['keywords']) && !empty($param['keywords'])){
            $where[]=['o.order_sn','like','%'.$param['keywords'].'%'];
        }
        if (isset($param['mintime']) && !empty($param['mintime'])){
            $mintime=strtotime($param['mintime']);
            $where[]=['o.finished_time','>', $mintime];
        }
        if (isset($param['maxtime']) && !empty($param['maxtime'])){
            $maxtime=strtotime($param['maxtime']);
            $where[]=['o.finished_time','<',$maxtime];
        }
        if (isset($param['order_status']) && count($param['order_status'])<=8){
            $where[]=['o.status','in',$param['order_status']];
        }
        if (isset($param['minmoney']) && !empty($param['minmoney'])){
            $where[]=['o.goods_amount','>', $param['minmoney']];
        }
        if (isset($param['maxmoney']) && !empty($param['maxmoney'])){
            $where[]=['o.goods_amount','<',$param['maxmoney']];
        }

        return  $where;



    }



}